-
Notifications
You must be signed in to change notification settings - Fork 1
Add ECS0005: prefer formattablestring for culture specific strings #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ECS0005: prefer formattablestring for culture specific strings #49
Conversation
…estring-for-culture-specific-strings
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
cc6f104
to
c8a3ce1
Compare
src/EffectiveCSharp.Analyzers/FormattableStringForCultureSpecificStringsAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/EffectiveCSharp.Analyzers/FormattableStringForCultureSpecificStringsAnalyzer.cs
Outdated
Show resolved
Hide resolved
…ce for .NET Framework and .NET 6+
7977558
to
8ca44f8
Compare
5601654
to
efbeb91
Compare
This pull request introduces a new Roslyn analyzer and associated code fix provider to enforce best practices for culture-specific string formatting in C#. The analyzer identifies cases where `FormattableString` or `string.Create` should be used instead of string for interpolated strings, depending on the target framework version. The code fix provider automatically suggests the appropriate replacement. ## Changes - Analyzer: `FormattableStringForCultureSpecificStringsAnalyzer` - Detects culture-specific string usage and recommends either `FormattableString`, `string.Create`, or `string.Format` based on the .NET version. - Code Fix Provider: `FormattableStringForCultureSpecificStringsCodeFixProvider` - Provides automated fixes based on the analyzer's recommendations. - Tests: Comprehensive unit tests covering various scenarios, including different .NET versions and complex string interpolation cases. This analyzer aligns modern C# and .NET practices, particularly Stephen Toub's guidance on using `string.Create` in .NET 6+
This pull request introduces a new Roslyn analyzer and associated code fix provider to enforce best practices for culture-specific string formatting in C#. The analyzer identifies cases where
FormattableString
orstring.Create
should be used instead of string for interpolated strings, depending on the target framework version. The code fix provider automatically suggests the appropriate replacement.Changes
FormattableStringForCultureSpecificStringsAnalyzer
FormattableString
,string.Create
, orstring.Format
based on the .NET version.FormattableStringForCultureSpecificStringsCodeFixProvider
This analyzer aligns modern C# and .NET practices, particularly Stephen Toub's guidance on using
string.Create
in .NET 6+